package com.hmall.order.web;

import com.hmall.order.pojo.Order;
import com.hmall.order.pojo.RequestParams;
import com.hmall.order.service.IOrderService;
import com.hmall.order.threadlocal.UserHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("order")
public class OrderController {

   @Autowired
   private IOrderService orderService;

   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      log.info("拦截其中得到的userid--->{}", UserHolder.getUser());
      return orderService.getById(orderId);
   }


   @PostMapping
   public Order createOrder(@RequestBody RequestParams params) {
      return orderService.createOrder(params);
   }

}
